Actually move out of Box in moving-out-of-Box test#2204
Actually move out of Box in moving-out-of-Box test#2204ehuss merged 1 commit intorust-lang:masterfrom
Conversation
src/expressions/operator-expr.md
Outdated
| assert_eq!(*y, 11); | ||
| let z = Box::new(NoCopy); | ||
| let _: NoCopy = *z; | ||
| let _z: NoCopy = *z; |
There was a problem hiding this comment.
drop::<NoCopy>(*z) or { *z } would also get the job done here. Maybe the drop would be the most explicit? Using a pattern binding is a bit more subtle; I expect it may not be obvious if you're not deeply in the weeds already that _z differs from _.
src/expressions/operator-expr.md
Outdated
| let z = Box::new(NoCopy); | ||
| let _: NoCopy = *z; | ||
| let _z: NoCopy = *z; |
There was a problem hiding this comment.
I think to maintain consistency with the rest of the example above, it's fine to just assign to a local.
Since we have kind of run out of letters, and to avoid any confusion around _ prefixes, how about just using different variable names here? Such as a and b or whatever.
There was a problem hiding this comment.
Using a, b, etc. sounds fine to me; I've done that (after slightly misinterpreting and first renaming _z to a ^^). I broke the pattern intentionally since that assignment is part of the example for Box (I figured each reference/pointer would get one letter), but I agree about avoiding _ prefixes. In any case, I don't have a strong preference.
cf23bba to
93bd844
Compare
93bd844 to
95aaeee
Compare
Update books ## rust-embedded/book 1 commits in e88aa4403b4bf2071c8df9509160477e40179099..2463edeb8003c5743918b3739a9f6870b86396f5 2026-03-11 17:49:58 UTC to 2026-03-11 17:49:58 UTC - Update teaching material duration for bare-metal Rust (rust-embedded/book#409) ## rust-lang/reference 7 commits in c49e89cc8c7c2c43ca625a8d5b7ad9a53a9ce978..7446bf9697c95d155eef33c6a9d91fbd29a5e359 2026-03-18 01:46:01 UTC to 2026-03-10 18:10:22 UTC - Update `must_use` to use the attribute template (rust-lang/reference#1892) - Add a rule that enum discriminants may not use generic parameters (rust-lang/reference#2206) - Actually move out of Box in moving-out-of-Box test (rust-lang/reference#2204) - Add special cases and links relating to dereferencing boxes (rust-lang/reference#2075) - Move shebang into its own subchapter (rust-lang/reference#2199) - Fields of enums and unions should be allowed to overlap (rust-lang/reference#2168) - [type layout] Clarify size and alignment of pointers to unsized types (rust-lang/reference#2201)
Update books ## rust-embedded/book 1 commits in e88aa4403b4bf2071c8df9509160477e40179099..2463edeb8003c5743918b3739a9f6870b86396f5 2026-03-11 17:49:58 UTC to 2026-03-11 17:49:58 UTC - Update teaching material duration for bare-metal Rust (rust-embedded/book#409) ## rust-lang/reference 7 commits in c49e89cc8c7c2c43ca625a8d5b7ad9a53a9ce978..7446bf9697c95d155eef33c6a9d91fbd29a5e359 2026-03-18 01:46:01 UTC to 2026-03-10 18:10:22 UTC - Update `must_use` to use the attribute template (rust-lang/reference#1892) - Add a rule that enum discriminants may not use generic parameters (rust-lang/reference#2206) - Actually move out of Box in moving-out-of-Box test (rust-lang/reference#2204) - Add special cases and links relating to dereferencing boxes (rust-lang/reference#2075) - Move shebang into its own subchapter (rust-lang/reference#2199) - Fields of enums and unions should be allowed to overlap (rust-lang/reference#2168) - [type layout] Clarify size and alignment of pointers to unsized types (rust-lang/reference#2201)
I looked at #2075 again after it merged and noticed a test I wrote there is wrong; oops!
let _ = $place;doesn't actually perform a move; a place-to-value coercion is needed.